<!DOCTYPE html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>后台管理</title>
	<link rel="shortcut icon" type="image/ico" href="/images/favicon.ico">
	<link href="/css/admin/style.css" rel="stylesheet" type="text/css" />
	<link href="/css/validator.css" rel="stylesheet" type="text/css" />
	<script src="/js/jquery-1.4.4.js" type="text/javascript" charset="UTF-8"></script>
	<script src="/js/formValidator-4.1.1.js" type="text/javascript" charset="UTF-8"></script>
	<script src="/js/formValidatorRegex.js" type="text/javascript" charset="UTF-8"></script>
	<script type="text/javascript" src="/js/admin.js"></script>
	
	<script>
	$(document).ready(function(){
		$.formValidator.initConfig({formID:"form1",autoTip:true,tidyMode:true,onError:function(msg){}});
		
	    $("#name").formValidator({onShow:"请输入栏目名称",onFocus:"至少2个字符",onCorrect:"输入正确"}).inputValidator({min:2,max:200,onError:"输入不合法，请确认"});
	    $("#review").formValidator({empty:true,onShow:"请输入导读，可以为空",onFocus:"至少5个字符",onCorrect:"输入正确"}).inputValidator({min:5,max:500,onError:"输入不合法，请输入5-500个字符，请确认"});
	});
	
	function loadPage(){
		var url = document.getElementById("url");
		
		if(url.value==null || ""==url.value){
			alert("URL不能为空");return false;
		}
		
	  $.ajax({ 
	  	url: "/admin/accessExtSite/index?url="+url.value, 
	  	success: function(data){
       		var josnObj=eval('('+data+')');  
       		
       		var success = josnObj["success"];
       		if(success==-1){
       			alert("加载页面出错，页面可能暂时不能访问，或者URL拼写错误！");return false;
       		}
       		
       		var dataJson = josnObj["data"];
       		var title = dataJson["title"];
       		var domain = dataJson["domain"];
       		var siteID = dataJson["siteID"];
       		var siteName = dataJson["siteName"];
       		
			if(siteID==null || siteID==""){
				alert("获取站点ID异常，请确认当前域名站点是否在本系统存在。");
			}
			//alert(dataJson["title"]+",domain="+dataJson["domain"]);
			$("#title").val(title);
			$("#siteID").val(siteID);
			$("#siteName").html(siteName);
      }});
	}
	
	function check(){
		 var id = $("#id").val();
		 var parentID = $("#parentID").val();
		 
		 //alert("id="+ id + ",parentID=" + parentID);
		 if(parentID!=0 && parentID!=id){
		 	alert("当前信息已关联其它信息，不能更改栏目");return false;
		 }
		 
		 var siteID = $("#siteID");
		 var value =siteID.val();
		 if(value==null || value=="" || parseInt(value) < 1){
		 	alert("获取站点错误,请重新获取");return false;
		 }
		
		 return true;
	}
	</script>
</head>

<body>
	
		<#include "/admin/nav.ftl">
		
		<div id="wrapper">
			<div id="nav_trail"><a href="#">后台管理</a> 推荐管理</div>
			<div id="content">
			
				<!-- 左边菜单 -->
				<#include "/admin/left_menu.ftl">
				<!-- 左边菜单 -->
				
				<script>
					menusel('m_item${item.id}');
				</script>
	
	
				<div class="right_area">
					<div class="cbar">
			            
			              <ul>
			                <li ><a href="/admin/info/index?itemID=${item.id}">${item.name?default("")}列表</a></li>
			    			<li class="cbar-tag-sel">${item.name?default("")}编辑</li>
			              </ul>
			         </div><!-- cbar end -->
			         
			         <div class="cbox">
          
            <div class="ydbar">
      			<div class="info-title">${item.name?default("")}编辑</div>
    		</div>	
       		
       		<form id="form1" name="form1" method="post" action="/admin/info/update" onSubmit="return check();">
		         <input type="hidden" name="siteID" id="siteID" value="${info.siteID?default("")}"/>
		         <input type="hidden" name="id" id="id" value="${info.id}"/>
		         <input type="hidden" name="parentID" id="parentID" value="${info.parentID}"/>
		         <input type="hidden" name="client" id="client" value="1"/>
		         
		    <table cellspacing="0" cellpadding="0" border="0" class="table-f">
		      <tbody>
		      
		      <tr>
		        <td align="right" width="15%" class="formtdl">URL：</td>
		        <td align="left" colspan="2"><input type="text" id="url" size="90" name="url" value="${info.url?default("")}" ><input type="button" onClick="loadPage()" value="加载页面标题"/></td>
		        <td align="left" width="35%"><div id="urlTip" class="onShow">请输入URL</div></td>
		      </tr>
		      
		      <tr>
		        <td align="right" width="15%" class="formtdl">标题：</td>
		        <td align="left" colspan="2"><input type="text" id="title" size="90" name="title" value="${info.title?default("")}"></td>
		        <td align="left" width="35%"><div id="titleTip" class="onShow">请输入标题</div></td>
		      </tr>
		      
		      <tr>
		        <td align="right" width="15%" class="formtdl">导读：</td>
		        <td align="left" colspan="2"><textarea name="review" id="review" cols="86" rows="5" class="fl">${info.review?default("")}</textarea></td>
		        <td align="left" width="35%"><div id="reviewTip" class="onShow">导读可以空</div></td>
		      </tr>  
		      
		      <tr>
		        <td align="right" width="15%" class="formtdl">图片地址：</td>
		        <td align="left" colspan="2"><input type="text" id="imgUrl" size="90" name="imgUrl" value="${info.imgUrl?default("")}"></td>
		        <td align="left" width="35%"></td>
		      </tr>
		      
		      <tr>
		        <td align="right" width="15%" class="formtdl">所属站点：</td>
		        <td align="left" colspan="3"><span id="siteName">${site.name?default("")}</span>
		        <#--
		        <select name="siteID" id="siteID">
		        			<option value="-1">请选择</option>
		        	<#if siteList?exists>
		        		<#list siteList as site>
		        			<option value="${site.id}" <#if info.siteID==site.id>selected</#if> >${site.name?default("")}</option>
		        		</#list>
		        	</#if>
		        	</select>
		        --></td>
		      </tr>
		      
		      <tr>
		        <td align="right" width="15%" class="formtdl">所属栏目：</td>
		        <td align="left" colspan="3">
		        	<select name="itemID" autocomplete="off" <#if info.id!=info.parentID && info.parentID!=0> disabled="disabled" </#if> >
		        		<option value="0">请选择</option>
					<#if itemList?exists>
						<#list itemList as item>
							<option value="${item.id}" <#if info.itemID==item.id>selected</#if> >${item.name?default("")}</option>
						</#list>
					</#if>
					</select>
				</td>
		      </tr>
		     
		    </tbody></table>

    
		    <table width="100%" cellspacing="0" cellpadding="0" border="0">
		      <tbody><tr>
		          <td align="center">
		            <input type="submit" value="提交" id="button" class="inp-yd" name="button">
		            
		        </td></tr>
		    </tbody></table>
		  </form>
             
          </div><!-- cbox end -->
            
			            
			        </div><!-- right_area end -->
				</div>
				
				<div class="clear"></div>
			</div> <!-- content end-->
			<div id="footer"></div>
   		</div><!-- wrapper end-->
</body>
</html>